#ifndef LINESTRIPE_H
#define LINESTRIPE_H

#pragma warning(disable:4251)

#include <BPointArray>
#include <BLine2>
#include <BWidget>

using namespace BWE;

class LineStripe :public BWidget
{
	BOBJECT(LineStripe)
public:
	LineStripe();
	LineStripe(const BPointArray& linePoints);
	~LineStripe();

	virtual void copy(const BWidget* other) override;
	virtual BWidget* clone() const override;

	BLine2 line(BReal value) const;
	BPoint vertex(BReal value) const;
	BReal value(const BPoint& point) const;

	BReal length() const;
	bool closeLoop() const;
	bool reverse();

	void setLinePoints(const BPointArray& linePoints);
	const BPointArray& linePoints() const;

	int pointCount() const;
	void setPoint(int index, const BPoint& point);
	const BPoint& point(int index) const;

	void setThickness(float thickness);
	float thickness() const;

	void appendPoint(const BPoint& point);
	const BPoint& head() const;
	const BPoint& tail() const;
	
	void setLineColor(const BColor& lineColor);
	const BColor& lineColor() const;

	void setHeadColor(const BColor& headColor);
	const BColor& headColor() const;

	void setTailColor(const BColor& tailColor);
	const BColor& tailColor() const;

	using BWidget::query;
	virtual bool query(const BString& text, BValue& value) const;

protected:
	virtual void styleEvent(const BEvent& event);
	virtual void freshEvent(const BEvent& event);
	virtual void paintEvent(const BEvent& event);

private:
	float			_thickness;
	BPointArray		_linePoints;
	BReal			_length;
	bool			_dirty;
	BColor			_lineColor;
	BColor			_headColor;
	BColor			_tailColor;
};

#endif
